\chapter*{Preface}
\addcontentsline{toc}{chapter}{Preface}
\chaptermark{Preface}

Business is driven by data.  Programmers make their money storing, retrieving,
and organizing data.  The first time I did this was twenty years ago,
when users had VT220 terminals.  While the presentation has moved
from dumb terminals to web browsers, the backends are strikingly
similar.

Similarity in computing leads to pattern recognition.  Patterns lead to
frameworks.  Frameworks lead to generators.  This book explains the Gantry
framework for Perl powered, web delivered applications and Bigtop, Gantry's
code generation framework.

Gantry grew up in a mid-western cable, internet, and phone service provider as
a back office application server.  If you follow it all the way back to
its most humble beginnings, it was already 10 years old as 2006 ended.
But it has received a couple of major revisions, the last of which was
launched in late 2005, as the open source version known as
Gantry.

The focus of Gantry is like the focus of Perl.  Both are tools for getting
jobs done.  As such, while it tries to be helpful, Gantry is always willing
to let you do what you need to do.  For instance, we generally use it
in a completely separated MVC fashion, using DBIx::Class to describe
our data model, simple controllers (many of which are made by Bigtop)
to drive the processing of data, and Template Toolkit to display our results.
But, if you don't like that approach, Gantry will happily let you
work in your own style.  For instance, not only can you code HTML
directly into your controller, but there is a whole Utils module
designed to help you do it (see Chapter \ref{chap:contactus} for an example).

Bigtop is my attempt to demonstrate that all database backed applications
are highly similar, not in the particulars of what they store, but
in their work flows (or use cases if you prefer modern nomenclature).
Since the process of taking data from a user, storing it in a database,
and delivering it back to the same or different users is so similar in
requirement, there ought to be a unified way of describing such applications.
My way is the Bigtop language.

Bigtop allows you to describe the tables, controllers, and configuration
of your application within a single source file.  It even provides a handy
browser delivered editor, tentmaker, to maintain those descriptions.
Then, when the data model needs to change, you can make the changes in
one spot, regenerate the code and restart the application with only a few
simple steps.

This book explains in detail how to build web applications using
Gantry, with help from Bigtop.  It does not go into any detail about
how the web works.  There are no pictures of servers and client machines.
I'm assuming that you know a bit about how to program, especially in
the context of the web.  If you aren't at this level, you need a different
book.  I recommend O'Reilly's \emph{CGI Programming in Perl}.

\section*{Contents of this Book}

This book is organized into four parts.  I'll give a brief tour of each
one here.  The first two parts are tutorials of increasing complexity.

In the beginning you must install software.  Chapter \ref{chap:install}
explains how to get Gantry and Bigtop onto your system.  Once you've
installed those, Chapter \ref{chap:simpleex} will happily show a small
example to whet your appetite.  Chapter \ref{chap:deploy} explains how
to migrate from a stand alone server to \verb+mod_perl+ and from hard
coded configuration information to Gantry::Conf, which is a separate
subproject of Gantry.  This subproject is dedicated to providing the most
flexible and simple configuration management we could devise.  Part I
ends with Chapter \ref{chap:runtests}, which explains how to test Gantry
apps with default tests generated by bigtop and custom tests you write
yourself.

Part II provides three complete case studies.  First, Chapter
\ref{chap:contactus} shows how to write a one module Gantry app from
scratch.  The app is so simple there is no database and the controller
hard codes the HTML (with help from a Gantry module).  Then, Chapter
\ref{chap:billingapp} puts on a coat and tie to build a billing application
suitable for use by independent contract programmers.  Finally, Chapter
\ref{chap:jobadsapp} goes even further with a job description application
that needs many-to-many table relationships, user authentication,
and a per user change log.

The last two parts turn from tutorial to reference.  Part III is
a reference for Gantry.  It begins in Chapter \ref{chap:fullcrud} with a 
discussion of all things CRUD (Create, Retrieve, Update, Delete).
Chapter \ref{chap:plugins} explains Gantry's plug-in scheme.
A tour of the API for Gantry objects follows in Chapter \ref{chap:site}.
The Gantry reference concludes with an explanation of how to bring
in your favorite ORM in Chapter \ref{chap:orms}.

Part IV is a reference for Bigtop.
Chapter \ref{chap:backends} describes all the existing Bigtop backends
including details on what they make and how to configure them.
The browser delivered tentmaker editor takes center stage in
Chapter \ref{chap:tentref}.  The use of Bigtop ends with Chapter
\ref{chap:bigsyntax}, which describes the Bigtop language in full
detail; in case you want to use a text editor instead of tentmaker.

\section*{Acknowledgements}

This is not a huge book and it has not cost me my social or family life.
Yet, many people have helped to make it as useful as it is.  Here's thanks
to some of them.

When Frank Wiles hired me, he promised that
we would either switch to a new framework, or rewrite the aging one already
in use in the shop.  I'm happy he
gave us the chance to do the later.  He has provided constant encouragement
as Gantry and Bigtop came into existence, even though writing them cost a
considerable amount of shop time.  The future may show that it was a good
trade, but I'm thankful he had the courage to take that bet.  Frank also
conceived of and wrote Gantry::Conf.  Finally, he made lots
of constructive suggestions for this book.

Kevin Esteb is the first user of Gantry that ever sent us code.  We
appreciate his sharp questions, polite and helpful advice, and code
contributions.  I also thank Kevin for reading this book more than once
and for insisting that we finish it.

I've had no colleague better than Tim Keefer.  His drive for
clarity and simplicity has made Gantry and Bigtop usable in ways I
couldn't have conceived on my own.  I owe him a huge debt for constantly
insisting that things could be easier and easier to understand.

Thanks also to Derek Stout for the cover art and to my wife Lisa for making
me think that time spent writing this book was good for her productivity.\\

\noindent
Phil Crow\\
Lawrence, KS 2007
